/* asciiboard_const.h is a set of constants, including all reserved protocol
   codes. 
   
   Copyright (C) 2014 James Boyle
   
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
#ifndef ASCIIBOARD_CONST_HEADER_INCLUDED
#define ASCIIBOARD_CONST_HEADER_INCLUDED

/* asciiboard protocol */
/* data streaming */
#define RW_WAVE_ONE_CODE '['
#define RW_ENVELOPE_ONE_CODE '\\'
#define RW_MAP_ONE_CODE ']'
#define RW_WAVE_TWO_CODE '{'
#define RW_ENVELOPE_TWO_CODE '|'
#define RW_MAP_TWO_CODE '}'
/* channel mixing mode */
#define MIX_CODE 'M'
#define AM_CODE 'A'
#define FM_CODE 'F'
/* flag codes */
#define SYNC_ENV_CODE '~'
#define SILENCE_CODE '`'
/* all other codes e.g. next period */
#define HOLD_CODE 'H'
#define NEXT_VAL_CODE ','
#define NEXT_CODE '_'
#define RESET_CODE 0x7F

#define CODE_COUNT 0x80
#define CONCERT_A_CODE 'm' /* with default tone map = 440Hz */

/* global synth constants */
#define CHANS 2
#define WAVE_SIZE 1024 /* size of both wave tables */
#define ENVELOPE_MAX_SIZE 128 /* maximum number of envelope points */
#define TONE_COUNT 26 /* 26 possible tones in the synth */
#define MAX_POLYPHONY 10 /* maximum number of simultaneous notes */
#define SRATE 44100.0f /* audio sampling rate (Hz) */
#define PERIOD_SAMPLES 4096 /* samples in a period of audio */
#define CRATE (SRATE / PERIOD_SAMPLES) /* synth control rate (Hz) */

enum { FALSE = 0, TRUE };
enum { CH_ONE = 0, CH_TWO };

/* the function priority allows the user to choose how important they
   want their supplied function to be.  For example, a critical function
   will be made the first function to execute.  A medium priority function
   will be before the last and low priority functions, but after high and
   critical functions. */
enum priority { LAST = 0, LOW, MED, HIGH, CRITICAL };

/* ascii_error is a set of possible errors that can be returned from functions
  in the engine, to debug these in a program call asciiboard_error() */
enum ascii_error
{
	NO_ERROR = 0, INVALID_ARG, INSUFFICIENT_MEM, INVALID_DATA_STREAM,
	INVALID_AUDIO_BUFFER_SIZE, INVALID_AUDIO_BUFFER, DATA_STREAM_OVERRUN,
	VAL_BUFFER_OVERRUN, COPY_OVERRUN, PROCESSOR_TIMEOUT
} ASCII_ERROR;

#endif
